﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace TripleTestProject
{
    [TestClass()]
    public class TripleTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod()]
        public void TripleConstructorTest()
        {
            int a = 1; 
            int b = 1; 
            int c = 1; 
            Triple.Triple target = new Triple.Triple(a, b, c);
            Triple.Triple actual = new Triple.Triple(1, 1, 1);
            Assert.AreEqual(target, actual);
        }

        [TestMethod()]
        public void ToStringTest()
        {
            int a = 0; 
            int b = 0; 
            int c = 0; 
            Triple.Triple target = new Triple.Triple(a, b, c); 
            string expected =String.Format("{0} {1} {2}",target.A,target.B,target.C); 
            string actual;
            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void op_AdditionTest()
        {
            Triple.Triple firstNumber = new Triple.Triple(1,1,1); 
            Triple.Triple secondNumber = new Triple.Triple(1,1,1);
            Triple.Triple expected = new Triple.Triple(2,2,2); 
            Triple.Triple actual;
            actual = (firstNumber + secondNumber);
            Assert.AreEqual(expected,actual);
        }

        [TestMethod()]
        public void op_IncrementTest()
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple expected = new Triple.Triple(2,2,2);
            Triple.Triple actual;
            actual = (firstNumber)++;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void op_SubtractionTest()
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple secondNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple expected = new Triple.Triple(0, 0, 0); 
            Triple.Triple actual;
            actual = (firstNumber - secondNumber);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void op_EqualityTest() 
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple secondNumber = new Triple.Triple(1, 1, 1);
            bool actual = firstNumber == secondNumber;
            bool expected = true;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void op_InequalityTest() 
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple secondNumber = new Triple.Triple(1, 1, 1);
            bool actual = firstNumber != secondNumber;
            bool expected = false;

            Assert.AreEqual(expected,actual);
        }

        [TestMethod()]
        public void EqualsTest() 
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple secondNumber = new Triple.Triple(1, 1, 1);
            bool expected = true;
            Assert.AreEqual(expected,firstNumber.Equals(secondNumber));
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException), "You cant compare null")]
        public void EqualsNullTest() 
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple secondNumber = null;
            bool actual = firstNumber.Equals(secondNumber);
            bool expected = true;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ATest()
        {
            int a = 0; 
            int b = 0; 
            int c = 0; 
            Triple.Triple target = new Triple.Triple(a, b, c); 
            int expected = 0; 
            int actual;

            actual = target.A;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void BTest()
        {
            int a = 0; 
            int b = 0; 
            int c = 0; 
            Triple.Triple target = new Triple.Triple(a, b, c); 
            int expected = 0; 
            int actual;
            actual = target.B;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void CTest()
        {
            int a = 0; 
            int b = 0; 
            int c = 0; 
            Triple.Triple target = new Triple.Triple(a, b, c); 
            int expected = 0; 
            int actual;
            actual = target.C;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void CompaterToTest() 
        {
            Triple.Triple first = new Triple.Triple(1, 0, 1);
            Triple.Triple second = new Triple.Triple(1, 1, 0);

            int expected = 0;
            int actual = first.CompareTo(second);
            Assert.AreEqual(expected,actual);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentNullException), "You cant compare null")]
        public void CompaterTonNullTest() 
        {
            Triple.Triple first = new Triple.Triple(1, 0, 1);
            Triple.Triple second = null;
            first.CompareTo(second);
        }

        [TestMethod()]
        public void IClonableTest() 
        {
            Triple.Triple firstNumber = new Triple.Triple(1, 1, 1);
            Triple.Triple otherNumber = (Triple.Triple)firstNumber.Clone();
            firstNumber++;
            Triple.Triple actual = new Triple.Triple(1, 1, 1);
            Assert.AreEqual(otherNumber, actual);
        }

        [TestMethod()]
        public void FirstIndexTest() 
        {
            Triple.Triple test = new Triple.Triple(1, 2, 1);
            int expected = 1;
            int actual = test[0];
            Assert.AreEqual(expected, actual);

        }

        [TestMethod()]
        public void SecondIndexTest()
        {
            Triple.Triple test = new Triple.Triple(1, 2, 1);
            int expected = 2;
            int actual = test[1];
            Assert.AreEqual(expected, actual);

        }

        [TestMethod()]
        public void ThirdIndexTest()
        {
            Triple.Triple test = new Triple.Triple(1, 2, 1);
            int expected = 1;
            int actual = test[2];
            Assert.AreEqual(expected, actual);

        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentOutOfRangeException),"Invalid index")]
        public void IndexOutOfRangeTest() 
        {
            Triple.Triple test = new Triple.Triple(1, 1, 1);
            int expected = test[5];
            int actual = 1;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void SetFirstIndexTest() 
        {
            Triple.Triple tst = new Triple.Triple(1, 2, 3);
            tst[0] = 2;
            int expected = 2;
            int actual = tst[0];
            Assert.AreEqual(expected,actual);
        }

        [TestMethod()]
        public void SetSecondIndexTest()
        {
            Triple.Triple tst = new Triple.Triple(1, 2, 3);
            tst[1] = 10;
            int expected = 10;
            int actual = tst[1];
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void SetThirdIndexTest()
        {
            Triple.Triple tst = new Triple.Triple(1, 2, 3);
            tst[2] = 5;
            int expected = 5;
            int actual = tst[2];
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [ExpectedException(typeof(ArgumentOutOfRangeException), "Invalid index")]
        public void SetIndexOutofRange() 
        {
            Triple.Triple test = new Triple.Triple(1, 1, 1);
            test[6] = 1;
        }
    }
}
